<template>
  <div id="searchViewVideo">
    <ul>
      <li v-for="(item, index) in list" :key="index" @click="playmv(item)">
        <div>
          <div>
            <div class="videoBg">
              <div
                :style="{
                  backgroundImage: 'url(' + item.coverUrl + ')',
                  backgroundSize: '100%,100%',
                }"
              ></div>
              <div
                :style="{
                  backgroundImage: 'url(' + item.coverUrl + ')',
                  backgroundSize: '100%,100%',
                }"
              ></div>
            </div>
            <div>
              <div>{{ item.title }}</div>
              <div>
                <div>
                  <van-icon name="eye-o" /><sapn
                    >{{ (item.playTime / 10000).toFixed(1) }}万</sapn
                  >
                </div>
                <div>
                  <van-icon name="good-job-o" /><span
                    >{{ (item.durationms / 10000).toFixed(1) }}万</span
                  >
                </div>
                <div></div>
              </div>
            </div>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import { searchKeyWords } from "network/api/SearchViewApi";
export default {
  data() {
    return {
      list: [],
    };
  },
  computed: {
    curretKeyWord() {
      return this.$store.state.keyWord;
    },
  },
  methods: {
    playmv(item) {
      console.log(item);
      this.$emit("playmv", item);
    },
  },
  mounted() {
    searchKeyWords(this.curretKeyWord, 0, 1014).then((res) => {
      console.log(res);
      this.list = res.data.result.videos;
    });
  },
  watch: {
    curretKeyWord(newV, oldV) {
      searchKeyWords(this.curretKeyWord, 0, 1014).then((res) => {
        console.log(res);
        this.list = res.data.result.videos;
      });
    },
  },
};
</script>

<style lang="less">
#searchViewVideo {
  @videoWidth: 50%;

  ul {
    padding-top: 10px;
    li {
      float: left;
      width: @videoWidth;
      height: 0;
      padding-bottom: @videoWidth*1.5;
      margin-top: 10px;
      > div {
        width: 90%;
        height: 0;
        margin: 0 auto;
        border-radius: 5px;
        padding-bottom: 150%;
        overflow: hidden;
        background-color: #fff;
        position: relative;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
        > div {
          position: absolute;
          left: 0;
          right: 0;
          bottom: 0;
          top: 0;
          .videoBg {
            width: 100%;
            height: 75%;
            overflow: hidden;
            position: relative;
            > div:first-child {
              position: absolute;
              width: 100%;
              height: 100%;
              background: url(https://p1.music.126.net/dCVG0eW-Fz1AXfe3z2ujhA==/109951163024566234.jpg);
              background-size: 100% 100%;
              filter: blur(5px);
              transform: scale(1.2);
            }
            > div:last-child {
              position: absolute;
              top: 50%;
              left: 50%;
              transform: translate(-50%, -50%);
              width: 90%;
              height: 60px;
              background: url(https://p1.music.126.net/dCVG0eW-Fz1AXfe3z2ujhA==/109951163024566234.jpg);
              background-size: 100% 100%;
            }
          }
          > div:last-child {
            display: flex;
            height: 25%;
            flex-direction: column;
            > div {
              &:first-child {
                font-weight: bold;
                font-size: 12px;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
              }
              &:last-child {
                color: gray;
                font-size: 5px;
                display: flex;
                > div {
                  flex: 1;
                }
              }
              flex: 1;
              line-height: 40px;
            }
          }
        }
      }
    }
  }
}
</style>